package com.wangwei.modules.controller

import com.wangwei.modules.entity.User
import com.wangwei.modules.service.MyService
import com.wangwei.modules.servlet.spring.Autowired
import com.wangwei.modules.servlet.spring.Controller
import com.wangwei.modules.servlet.spring.RequestMapping
import com.wangwei.modules.servlet.spring.ResponseBody
import org.springframework.ui.Model


@Controller
class UserController {

	@Autowired
	lateinit var service: MyService

	@RequestMapping("users")
	fun users(id: Integer, model: Model): Any {

		var a: List<HashMap<String, String>> = service.db.getAll("SELECT * from `user` where id=$id");
		model.addAllAttributes(a.get(0))
		return "/user/userInfo.jsp"
	}

	@RequestMapping("/user/addUser")
	fun addUser(user: User): Any {
		return "/user/add.jsp"
	}

	@ResponseBody
	@RequestMapping("uid")
	fun ssss(id: Integer): Any {
		return  service.db.getAll("SELECT * from `user` where id=$id");
	}

}